#include "and_gate.h"

NodeAndGate::NodeAndGate(Node *parent, NodeAndGateParam params) :
    Node(parent)
{
    List<PortInDirect<bool> *> tmp_885061504;
    for(int temp_885079736=0; temp_885079736<params.num_of_ports; temp_885079736+=1)
    {
        tmp_885061504.append(new PortInDirect<bool>(this));
    }
    port_and_ins = tmp_885061504;
    port_and_out = new PortOut<bool>(this);
}

NodeTaskList NodeAndGate::tasks() const
{
    NodeTaskList list;
    list.append(static_cast<NodeTask>(&NodeAndGate::task_check_all_in));
    return list;
}

void NodeAndGate::task_check_all_in()
{
    for(int temp_885077160=0; temp_885077160<port_and_ins.size(); temp_885077160+=1)
    {
        PortInDirect<bool> * and_in = port_and_ins[temp_885077160];
        if(!(and_in->get()))
        {
            port_and_out->put(false);
            return;
        }
    }
    port_and_out->put(true);
}